home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJINC106.ARJ / CTYPE.H < prev    next >
C/C++ Source or Header  |  1992-03-09  |  2KB  |  79 lines

  1. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  2. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  3. ** Rochester NH, 03867-2954, USA.
  4. */
  5.  
  6. /*
  7.  Here's a ctype.h for SunOS-3 and vax 4.3BSD.  
  8.  It will probably work on most BSD derived systems. 
  9.  Just compare it to the C version to verify.
  10.  No big deal, but it will save you some typing.
  11. */
  12.    
  13. #ifndef _ctype_h
  14. #define _ctype_h
  15.  
  16. #include <stdio.h>  /* sorry, but needed for USG stuff */
  17.    
  18. #define _U 01
  19. #define _L 02
  20. #define _N 04
  21. #define _S 010
  22. #define _P 020
  23. #define _C 040
  24.  
  25.  
  26. #if defined(USG) || defined(DGUX)
  27. #define _B 0100 /* different from BSD */
  28. #define _X 0200 /* different from BSD */
  29. #else
  30. #define _X 0100
  31. #define _B 0200
  32. #endif
  33.  
  34.  
  35. #ifdef DGUX
  36. #define CTYPE_TYPE      short
  37. #else
  38. #define CTYPE_TYPE      char
  39. #endif
  40.  
  41. #if defined(DGUX) || defined(USG) || defined(hpux)
  42. #define _ctype_ _ctype
  43. #endif
  44.  
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. extern  CTYPE_TYPE      _ctype_[];
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52.    
  53. #define isalpha(c)  ((_ctype_+1)[c]&(_U|_L))
  54. #define isupper(c)  ((_ctype_+1)[c]&_U)
  55. #define islower(c)  ((_ctype_+1)[c]&_L)
  56. #define isdigit(c)  ((_ctype_+1)[c]&_N)
  57. #define isxdigit(c) ((_ctype_+1)[c]&(_X|_N))
  58. #define isspace(c)  ((_ctype_+1)[c]&_S)
  59. #define ispunct(c)  ((_ctype_+1)[c]&_P)
  60. #define isalnum(c)  ((_ctype_+1)[c]&(_U|_L|_N))
  61. #define isprint(c)  ((_ctype_+1)[c]&(_P|_U|_L|_N|_B))
  62. #define isgraph(c)  ((_ctype_+1)[c]&(_P|_U|_L|_N))
  63. #define iscntrl(c)  ((_ctype_+1)[c]&_C)
  64. #define isascii(c)  ((unsigned)(c)<=0177)
  65. #define toupper(c)  (islower(c)? (c-'a'+'A') : c)
  66. #define tolower(c)  (isupper(c)? (c-'A'+'a') : c)
  67. #define toascii(c)  ((c)&0177)
  68.  
  69.  
  70. #ifdef _ctype_
  71. #undef _ctype_
  72. #endif
  73.  
  74. #ifdef CTYPE_TYPE
  75. #undef CTYPE_TYPE
  76. #endif
  77.  
  78. #endif _ctype_h
  79.